package com.winit.common.support.config;

import com.winit.common.filter.SessionValidFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by wangjian on 17/8/18.
 */
@Configuration
public class FilterConfig {

    @Value("${request_allow_ips}")
    private String request_allow_ips;

    @Bean
    public FilterRegistrationBean SessionValidFilterRegistration() {
        FilterRegistrationBean bean = new FilterRegistrationBean(new SessionValidFilter());
        bean.addUrlPatterns("/api/v1/*");
        bean.addInitParameter("request_allow_ips", request_allow_ips);
        return bean;
    }

}
